class smx_java {
  require smx_os

  Exec { path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/' ] }

  package { 'tomcat-7.0.33' :
    ensure => absent,
  }

  package { 'java-1.7.0-openjdk-devel' :
    ensure  => absent,
    require => Package['tomcat-7.0.33'],
  }

  package { 'java-1.7.0-openjdk' :
    ensure  => absent,
    require => Package['tomcat-7.0.33'],
  }

  file { '/vagrant/vagrant/download_jdk.sh':
    ensure => present,
    mode   => '0755',
    source =>  "puppet:///modules/smx_java/download_jdk.sh",
  }

  exec { 'download_jdk':
    cwd       => '/vagrant/vagrant',
    command   => "/vagrant/vagrant/download_jdk.sh",
    timeout   => '300', # half an hour, at most
    logoutput => true,
    require   => File['/vagrant/vagrant/download_jdk.sh'],
  }

  package { 'jdk1.8.0_45':
    ensure   => present,
    provider => rpm,
    require  => Exec['download_jdk'],
    source   => "/tmp/vagrant-cache/wget/jdk1.8/jdk-8u45-linux-x64.rpm",
  }
}
